package com.admin.business.personalCenter.venusSysUserReview;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 专家审核记录表
 * @create: 2023-11-23 14:59:29
 **/
@Service("venusSysUserReviewService")
@Slf4j
public class VenusSysUserReviewService{

    @Resource
    VenusSysUserReviewDao venusSysUserReviewDao;

    /**
     * 添加专家审核记录表,获取id数据
     *
     * @param cdoRequest - id:ID
     *                   - user_id:用户ID
     *                   - review_name:真实姓名
     *                   - user_review:审核用户id
     *                   - review_number:手机号
     *                   - identification:身份证号码
     *                   - introduce:个人简介
     *                   - lawyer_img:律师资格证
     *                   - other_img:其他资格证
     *                   - service_fee:回答问题收取费用
     *                   - status:审核状态：0、未审核，1、已审核, 2、审核失败，3.已禁用
     *                   - begin_time:创建时间
     *                   - update_time:更新时间
     *                   - reason:审核原因
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return addVenusSysUserReview(CDO cdoRequest) {
        venusSysUserReviewDao.addVenusSysUserReview(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新专家审核记录表数据
     *
     * @param cdoRequest - id:ID
     *                   - user_id:用户ID
     *                   - review_name:真实姓名
     *                   - user_review:审核用户id
     *                   - review_number:手机号
     *                   - identification:身份证号码
     *                   - introduce:个人简介
     *                   - lawyer_img:律师资格证
     *                   - other_img:其他资格证
     *                   - service_fee:回答问题收取费用
     *                   - status:审核状态：0、未审核，1、已审核, 2、审核失败，3.已禁用
     *                   - begin_time:创建时间
     *                   - update_time:更新时间
     *                   - reason:审核原因
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return updateVenusSysUserReviewById(CDO cdoRequest) {
        venusSysUserReviewDao.updateVenusSysUserReviewById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除专家审核记录表数据
     *
     * @param cdoRequest - id:ID
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return deleteVenusSysUserReviewById(CDO cdoRequest){
        int count = venusSysUserReviewDao.deleteVenusSysUserReviewById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除专家审核记录表数据
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return deleteVenusSysUserReview(CDO cdoRequest) {
        int count = venusSysUserReviewDao.deleteVenusSysUserReview(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取专家审核记录表数据
     *
     * @param cdoRequest - id:ID
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysUserReviewById(CDO cdoRequest) {
        CDO cdoMapperResult = venusSysUserReviewDao.getVenusSysUserReviewById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取专家审核记录表数据列表
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysUserReviewListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusSysUserReviewDao.getVenusSysUserReviewListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusSysUserReviewDao.getVenusSysUserReviewCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取专家审核记录表数据列表
     *
     * @param cdoRequest - id:ID
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysUserReviewListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusSysUserReviewDao.getVenusSysUserReviewListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusSysUserReviewDao.getVenusSysUserReviewCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
